<?php

class DB_HISTORY extends ORM_Table {
    
    static protected $table_name = 'history';
    
    static public function getTableName($params = null) {
        return self::$table_name;
    }
    
    /**
     * 保存
     * @param type $weibo_id
     * @param type $array 
     */
    static function store($array){
        $weibo_id   = $array['id'];
        $rs = ORM_Finder::findOne(DB_HISTORY, array('weibo_id'=>$weibo_id,'up_at'=>date('Y-m-d')));
        if(!$rs){
            $rs = new DB_HISTORY();
            $rs->setUpAt(date('Y-m-d'));
            $rs->setWeiboId($weibo_id);
        }
        
        $rs->setFollowersCount($array['followers_count']);
        $rs->setFriendsCount($array['friends_count']);
        $rs->setStatusesCount($array['statuses_count']);
        $rs->save();
        return $rs;
    }
    
    
}

?>
